home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / engine.arc / WHERE.PAS < prev   
Pascal/Delphi Source File  |  1989-03-29  |  2KB  |  54 lines

  1. {$R-,S+,I+,D+,F-,V-,B-,N-,L+ }
  2. {$M $4000,0,0}
  3. PROGRAM where;
  4.   (********************************************************)
  5.   (* Uses SearchEngine to find and display matching files *)
  6.   (* in any subdirectory and total their sizes.  E.g., to *)
  7.   (* find all Pascal files, execute WHERE *.PAS           *)
  8.   (********************************************************)
  9. USES DOS,Engine;
  10.  
  11. VAR
  12.   template, path : STRING;
  13.   ErrCode        : Byte;
  14.   Total          : LongInt;
  15.  
  16.   {$F+} PROCEDURE ShowFile(VAR S : SearchRec; path : PathStr); {$F-}
  17.   BEGIN
  18.     WriteLn(path + S.Name);
  19.     Total := Total + S.Size
  20.   END;
  21.  
  22.   PROCEDURE Validate;
  23.     {Validate the command line parameter}
  24.   VAR P : Byte;
  25.     Ext : ExtStr;
  26.   BEGIN
  27.     IF ParamCount <> 1 THEN
  28.       BEGIN
  29.         WriteLn('SYNTAX:  "WHERE [path]filespec"');
  30.         Halt;
  31.       END;
  32.     FSplit(ParamStr(1), path, template, Ext);
  33.     IF Length(path) = 2 THEN path := path + '\';
  34.     template := template + Ext;
  35.     (*IF no path specified, search from root of
  36.       current volume*)
  37.     IF path = '' THEN
  38.       BEGIN
  39.         GetDir(0, path);
  40.         IF Length(path) = 2 THEN path := path + '\'
  41.         ELSE path[0] := #3;
  42.       END;
  43.   END;
  44.  
  45.   BEGIN
  46.     Total := 0;
  47.     Validate;
  48.     WriteLn
  49.     ('Searching for "', template, '" in or below "', path, '"');
  50.     SearchEngineAll(path, template, Archive, ShowFile, ErrCode);
  51.     Writeln
  52.     ('These files occupy ',Total : 8,' bytes of disk space.')
  53.   END.
  54.